#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import cgi
import wsgiref.handlers
import os
from google.appengine.api import users
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.ext.webapp.util import run_wsgi_app

import wallpaper

class MapHandler(webapp.RequestHandler):

  def get(self):
    # self.response.out.write('Hello world!')
#    thumbs = wallpaper.get_urls_for_tags(tags=['gugong'], number=5)
    template_values = {
                       'no' : 'no',
                       }
    path = os.path.join(os.path.dirname(__file__), 'map_sam.html')
    self.response.out.write(template.render(path, template_values))
	
  def post(self):
    tag = self.request.get('tag')
    thumbs = wallpaper.get_urls_for_tags([tag], 4, 1)
    thumbs += (wallpaper.get_urls_for_tags([tag], 4, 2))
    thumbs += (wallpaper.get_urls_for_tags([tag], 4, 3))
    template_values = {
                       'thumbs' : thumbs,
                       }
    path = os.path.join(os.path.dirname(__file__), 'map_sam_thumbs.html')
    self.response.out.write(template.render(path, template_values))
#    self.response.out.write('hello')

